﻿using System.Text;
using RAP.Framework.Libary.DomTemplateBuilder.Element;
using RAP.Framework.Libary.DomTemplateBuilder.Interface;

namespace RAP.Framework.Libary.DomTemplateBuilder.Handler
{
  /// <summary>
  /// 
  /// </summary>
  public class ThrowErrorHandler : HandlerBase
  {
    /// <summary>
    /// 
    /// </summary>
    public new ThrowError Element
    {
      get
      {
        return base.Element as ThrowError;
      }
      set
      {
        base.Element = value;
      }
    }

    public override void DoRender(StringBuilder writer, object rootParamObject, object parentParamObject, ITemplateRenderContext context)
    {
      var sbError = new StringBuilder();
      base.DoRender(sbError, rootParamObject, parentParamObject, context);
      throw new ParamException(sbError.ToString().Trim(), this.Element.ErrorCode);
    }
  }
}
